package DB_Layer;

import static org.junit.Assert.*;

import org.junit.Before;
import org.junit.Test;

import Model_Layer.*;

public class Db_InvoiceTest {

	@Before
	public void setUp() throws Exception {
	}

	@Test
	public void testInsertInvoice() {
		
		Db_Invoice invDb = new Db_Invoice();
		Invoice invObj = new Invoice();
		
		invObj.setAmount(2);
		invObj.setPaymentDate("2014-09-20");
		
		
		try
		{
			invDb.insertInvoice(invObj);
			System.out.println("Invoice inserted");
			
		}
		catch(Exception e)
		{
			fail("Invoice not inserted");
		}
		
	}
	
	@Test
	public void testUpdateInvoice()
	{
		Db_Invoice invDb = new Db_Invoice();
		Invoice invObj = new Invoice();
		
		invObj.setAmount(3434);
		invObj.setPaymentDate("2014-09-20");
		invObj.setInvID(6);
		
		try
		{
			invDb.updateInvoice(invObj);
			System.out.println("Invoice updated");
		}
		catch(Exception e)
		{
			fail("Invoice not updated");
		}
	}
	
	@Test
	public void testDeleteInvoice()
	{
		Db_Invoice invDb = new Db_Invoice();
		
		try
		{
		invDb.delete(6);
		System.out.println("Invoice deleted");
		}
		catch(Exception e)
		{
			fail("Invoice not deleted");
		}
	}

}
